home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Hardcore Visual Basic 5.0 (2nd Edition)
/
Hardcore Visual Basic 5.0 - Second Edition (1997)(Microsoft Press).iso
/
Code
/
Goodies
/
SYSTEM~1
/
SYSCOL~1.FRM
< prev
next >
Wrap
Text File
|
1997-06-09
|
6KB
|
216 lines
VERSION 5.00
Object = "*\ASysColorControl.vbp"
Begin VB.Form frmSysColors
Caption = "ActiveX System Color Control Sample"
ClientHeight = 4485
ClientLeft = 60
ClientTop = 345
ClientWidth = 4770
LinkTopic = "Form1"
ScaleHeight = 4485
ScaleWidth = 4770
StartUpPosition = 2 'CenterScreen
Begin VB.CommandButton cmdPopup
Caption = "&Popup"
Height = 375
Left = 3000
TabIndex = 4
ToolTipText = "Display Popup Palette"
Top = 3120
Width = 1455
End
Begin VB.CommandButton cmdClick
Caption = "Set to Single &Click"
Height = 375
Left = 720
TabIndex = 3
ToolTipText = "Change ClickType"
Top = 3960
Width = 1575
End
Begin SystemColorControl.SysColors SysColors1
Height = 2235
Left = 360
TabIndex = 2
ToolTipText = "Select a Color"
Top = 1560
Width = 2310
_ExtentX = 4075
_ExtentY = 3942
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
DefaultColor = 8
End
Begin VB.CommandButton cmdExit
Caption = "&Exit"
Height = 375
Left = 3240
TabIndex = 1
ToolTipText = "Exit Sample"
Top = 3960
Width = 855
End
Begin VB.Label Label2
AutoSize = -1 'True
Caption = "Double Click Mode"
Height = 195
Left = 360
TabIndex = 10
Top = 1320
Width = 1350
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "System Color Value"
Height = 195
Left = 720
TabIndex = 9
Top = 720
Width = 1365
End
Begin VB.Label ShowValue
Alignment = 2 'Center
BackColor = &H80000005&
BorderStyle = 1 'Fixed Single
Height = 255
Left = 360
MouseIcon = "SysColorCtl.frx":0000
MousePointer = 99 'Custom
TabIndex = 8
ToolTipText = "Click for Hex Conversion"
Top = 960
Width = 2295
End
Begin VB.Label Label4
AutoSize = -1 'True
Caption = "Color Display"
Height = 195
Left = 3240
TabIndex = 7
Top = 120
Width = 915
End
Begin VB.Label Label3
AutoSize = -1 'True
Caption = "System Color Name"
Height = 195
Left = 720
TabIndex = 6
Top = 120
Width = 1380
End
Begin VB.Label ShowColor
BorderStyle = 1 'Fixed Single
Height = 975
Left = 2880
TabIndex = 5
Top = 360
Width = 1695
End
Begin VB.Label ShowName
Alignment = 2 'Center
BackColor = &H80000005&
BorderStyle = 1 'Fixed Single
Height = 255
Left = 360
TabIndex = 0
Top = 360
Width = 2295
End
End
Attribute VB_Name = "frmSysColors"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
'System Color Palette 1.0 - Sample Program
'Created by Randy Russell - June 1997
'Created using Microsoft Visual Basic 5.0
Dim MyColorVal As Long 'store color value for hex conversion
Dim MyPal As New clsSysColors
Private Sub cmdClick_Click()
'demonstrates use of the ClickType property
If SysColors1.ClickType = 2 Then
SysColors1.ClickType = 1
cmdClick.Caption = "Set to Double &Click"
Label2.Caption = "Single Click Mode"
Else
SysColors1.ClickType = 2
cmdClick.Caption = "Set to Single &Click"
Label2.Caption = "Double Click Mode"
End If
End Sub
Private Sub cmdExit_Click()
Unload Me
End Sub
Private Sub cmdPopup_Click()
'display popup palette
Dim X As Single, Y As Single
X = ((Width - 2310) / 2) + Left
Y = Top + 4000
MyPal.Popup X, Y
'if user did not cancel then get selection and update display
If MyPal.ColorName <> "" Then
MyColorVal = MyPal.Color 'color value
ShowColor.BackColor = MyColorVal
ShowValue.Caption = MyColorVal
ShowName.Caption = MyPal.ColorName 'color name
SysColors1.SetColor MyPal.ColorName
End If
End Sub
Private Sub Form_Load()
'display defaults
SetColors
If SysColors1.ClickType = 2 Then
cmdClick.Caption = "Set to Single &Click"
Else
cmdClick.Caption = "Set to Double &Click"
End If
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Set MyPal = Nothing
End Sub
Private Sub ShowValue_Click()
'switch between hex and decimal display
Static fhex As Boolean
If fhex Then
ShowValue.Caption = MyColorVal
ShowValue.ToolTipText = "Click for Hex Conversion"
fhex = False
Else
ShowValue.Caption = "h" & Hex(MyColorVal)
ShowValue.ToolTipText = "Click for Long Conversion"
fhex = True
End If
End Sub
Private Sub SysColors1_Click()
'if user did not cancel then get selection and update display
If SysColors1.SelectedColorName <> "" Then
SetColors
End If
End Sub
Private Sub SetColors()
'update display with new system color
MyColorVal = SysColors1.SelectedColor
ShowColor.BackColor = MyColorVal
ShowValue.Caption = MyColorVal
ShowName.Caption = SysColors1.SelectedColorName
End Sub